package com;

import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.api.VerboseProgressCallback;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.XMLParserException;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;

/**
 * mapper generator
 *
 * @Author: wangxiaonan
 * @Date: 2018/8/11
 **/
public class MapperGeneratorApplication {

    public static void main(String[] args) {
        System.out.println("---------------------- start ----------------------");
        try {

            ConfigurationParser parser = new ConfigurationParser(null);
            Configuration configuration = parser.parseConfiguration(new File(MapperGeneratorApplication.class.getResource("../generatorConfig.xml").getFile()));

            MyBatisGenerator myBatisGenerator = new MyBatisGenerator(configuration, null, null);
            myBatisGenerator.generate(new VerboseProgressCallback());

        } catch (InvalidConfigurationException e) {
            e.printStackTrace();
        } catch (XMLParserException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        System.out.println("---------------------- end ----------------------");
    }
}
